package rmi;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
/**
 * Ein einfacher Server nach dem Oracle Java Tutorial {@link <a href="http://download.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html">RMI-Tutorial</a>}.
 * @author Bernd Kahlbrandt
 * 
 */
public class Server implements IAnswer {
private Registry registry;
	@Override
	public String answer() throws RemoteException {
		return "Hallo von Server!";
	}
	/**
	 * @param args Keine.
	 */
	public static void main(String[] args) {
		 try {
	            Server server = new Server();
	            IAnswer stub = (IAnswer) UnicastRemoteObject.exportObject(server, 0);

	            server.registry = LocateRegistry.getRegistry();
	            server.registry.bind("Answer", stub);

	            System.err.println("Server bereit");
	        } catch (Exception e) {
	            System.err.println("Server exception: " + e.toString());
	            e.printStackTrace();
	        }
	}


}
